% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Graph plotting script for exercise 4 in OS.  v1
% Make sure you run my tester before running this script.
%
% Author : Amit Lavon
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

clear;
close all;

% Load tables
inAccess = importdata('access.txt');
inSpace = importdata('space.txt');

% Plot spaces
f1 = figure;
plot(inSpace(:,1), inSpace(:,2), 'b', inSpace(:,1), inSpace(:,3), 'r', 'LineWidth', 2);
title('File system space against block size');
legend('Linked list', 'iNode');
xlabel('Block size (bytes)');
ylabel('Total space (bytes)');

% Plot access
f2 = figure;
plot(inAccess(:,1), inAccess(:,2), 'b', inAccess(:,1), inAccess(:,3), 'r', 'LineWidth', 2);
title('Access time against block size');
legend('Linked list', 'iNode');
xlabel('Block size (bytes)');
ylabel('Average number of disk accesses per byte of data');

% Save to files
print(f1, '-djpeg', 'space.jpg');
fprintf('Saved space plot to ''space.jpg''\n');
print(f2, '-djpeg', 'access.jpg');
fprintf('Saved access plot to ''access.jpg''\n');



